<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page isELIgnored="false" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>内容检索</title>
    <base href="<%=request.getContextPath()%>/">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="static/layui/css/layui.css">
    <link rel="stylesheet" href="static/common/css/base.css">
    <link rel="stylesheet" href="static/common/css/article-list.css">
    <link rel="stylesheet" href="static/common/css/author-list.css">
    <script src="static/jquery/jquery.js"></script>
    <script src="static/jquery/js.cookie.js"></script>
    <script src="static/layui/layui.js"></script>
    <link rel="icon" href="static/images/favicon.ico">
</head>
<body>
<div class="main">
    <div class="header">
        <div class="nav">
            <div class="layui-row">
                <div class="layui-col-md2">
                    <div class="logo">
                        <a href="">
                            <img id="logo" src="" alt="">
                        </a>
                    </div>
                </div>
                <div class="layui-col-md8">
                    <div class="layui-row">
                        <div class="layui-col-md6">
                            <ul class="menu">
                                <li class="menu-item">
                                    <a href="page/index">
                                        <i class="layui-icon layui-icon-find-fill"></i>
                                        首页
                                    </a>
                                </li>
                                <li class="menu-item">
                                    <a href="page/category">
                                        <i class="layui-icon layui-icon-template-1"></i>
                                        分类
                                    </a>
                                </li>
                                <li class="menu-item">
                                    <a href="page/author">
                                        <i class="layui-icon layui-icon-group"></i>
                                        作者
                                    </a>
                                </li>
                            </ul>
                        </div>
                        <div class="layui-col-md6">
                            <div class="search">
                                <div class="search-group">
                                    <input id="search" type="text" placeholder="热门搜索">
                                    <i id="searchBtn" class="layui-icon layui-icon-search"></i>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="layui-col-md2">
                    <div class="layui-row">
                        <div class="layui-col-md6">
                            <div class="user">
                                <div class="avatar">
                                    <a id="dropMenu" href="javascript:;">
                                        <img id="vipAvatar" src="static/upload/avatar/defaultAvatar.jpg"
                                             class="layui-nav-img">
                                        <span id="vipName"></span>
                                    </a>
                                </div>
                                <div class="login">
                                    <div class="login-btn">
                                        <a href="javascript:;" onclick="showLoginWin(0)">登录</a>
                                    </div>
                                    <div class="reg-btn">
                                        <a href="javascript:;" onclick="showLoginWin(1)">注册</a>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md6">
                            <div class="apply">
                                <div class="apply-btn">
                                    <a href="javascript:;">
                                        <i class="layui-icon layui-icon-edit"></i>
                                        发布文章
                                    </a>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="body">
        <div class="content" style="display: block">
            <fieldset class="layui-elem-field">
                <legend>作者相关</legend>
                <div class="layui-field-box">
                    <div id="authorSearch" class="author-list"></div>
                </div>
            </fieldset>
            <fieldset class="layui-elem-field">
                <legend>博客相关</legend>
                <div class="layui-field-box">
                    <div id="articleSearch"></div>
                </div>
            </fieldset>
        </div>
    </div>
</div>
</body>
<script src="static/common/js/ajax.js"></script>
<script src="static/common/js/base.js"></script>
<script src="static/common/js/article.js"></script>
<script src="static/common/js/author.js"></script>
<script>
    const value = "${search}";
    if (!value) {
        layer.msg("查询异常！", {icon: 5}, function () {
            location.replace("page/index")
        })
    }
    $("#search").val(value);
    http.get('blog/search', {value}, function (res) {
        if (res.data.authorList.length > 0) {
            createAuthorList("authorSearch", res.data.authorList)
        } else {
            $("#authorSearch").text("暂无内容")
        }

        if (res.data.articleList.length > 0) {
            createArticleList("articleSearch", res.data.articleList)
        } else {
            $("#articleSearch").text("暂无内容")
        }
    })
</script>
</html>
